package org.jactao.cluster.loadbalance;

import org.jactao.rpc.LChannel;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by fanzetao on 2018/4/10.
 */
public class LRandomSelector extends LSelector {
    @Override
    public LChannel select(List<LChannel> channels) {
        List<LChannel> tempChannels = new ArrayList<>();
        for (LChannel client : channels) {
            tempChannels.add(client);
        }

        Collections.shuffle(tempChannels);
        return tempChannels.get(0);
    }
}
